//首页轮播swiper
var swiper = new Swiper('.swiper-container', {
    spaceBetween: 30,
    centeredSlides: true,
    loop:true,
    autoplay: {
        delay: 2500,
        disableOnInteraction: false,
    },
    pagination: {
        el: '.swiper-pagination',
        clickable: true,
    },
    navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
    },
});


//json
var vm = new Vue({
    el:"#app",
    data:{
        message:'正在请求数据...'
    },
    mounted(){
        axios
            .get('json/package.json')
            .then(response => (this.message = response.data.urls))
            .catch (function (error) {
                console.log(error);
            });
    }
})


//回到顶部
var t = document.querySelector("#fh");
window.onscroll = function () {
    if (document.documentElement.scrollTop > 700){
        t.style.display = "block";
    }else {
        t.style.display = "none";
    }
};
t.addEventListener('click',function () {
    window.scrollTo({
        top:0,
        behavior:'smooth'
    })
});

//搜索框点击事件
var search = document.querySelector(".search");
var close = document.querySelector(".close");
var sea = document.querySelector(".search-nr");

search.addEventListener('click',function () {
    sea.style.display = "block";
})
close.addEventListener('click',function () {
    sea.style.display = "none";
})















//手机端导航点击事件
var cv = document.querySelector(".cv");
var tab = document.querySelector(".tab");
var lang = "zh"
cv.addEventListener('click',function () {
    if (lang === 'zh'){
        lang = 'en';
    }else {
        lang = 'zh'
    }

    switch (lang){
        case 'en':
            tab.style.display = "block";
            break;
        case 'zh':
            tab.style.display = "none";
            break;
    }
})
       


//选项卡
var btn1 = document.querySelectorAll("nav>ul>li.bn");
var xuan = document.querySelectorAll(".pl>div");

for(var i=0;i<btn1.length;i++){
   btn1[i].index =i;
    btn1[i].addEventListener("mouseover",function () {
        for(var j=0;j<btn1.length;j++){
           xuan[j].style.display='none';
        }
       xuan[this.index].style.display='block';
    });

    for(var a=0;a<xuan.length;a++){
        xuan[0].addEventListener("mouseleave",function () {
            xuan[0].style.display='none';
        })
        xuan[1].addEventListener("mouseleave",function () {
            xuan[1].style.display='none';
        })
        xuan[2].addEventListener("mouseleave",function () {
            xuan[2].style.display='none';
        })
        xuan[3].addEventListener("mouseleave",function () {
            xuan[3].style.display='none';
        })
    }

}



//点击播放视频

var play = document.querySelector("#play");
var video = document.querySelector("#video");

var chadiao = document.querySelectorAll(".po-video>.chadiao");
/*console.log(chadiao[0]);*/
play.addEventListener("click" ,function(){
    video.style.display = "block";
    chadiao[0].style.display = "block";
});

chadiao[0].addEventListener("click" ,function(){
	video.style.display="none";
	chadiao[0].style.display = "none";
});



var ay = document.querySelector("#ay");

var vid = document.querySelector("#vid");

var chadiao = document.querySelectorAll(".po-video>.chadiao");
console.log(chadiao[1]);
ay.addEventListener("click" ,function(){
    vid.style.display = "block";
    chadiao[1].style.display = "block";
});

chadiao[1].addEventListener("click" ,function(){
    vid.style.display="none";
    chadiao[1].style.display = "none";
});


var py = document.querySelector("#py");

var vo= document.querySelector("#vo");

var chadiao = document.querySelectorAll(".po-video>.chadiao");
console.log(chadiao[2]);
py.addEventListener("click" ,function(){
    vo.style.display = "block";
    chadiao[2].style.display = "block";
});

chadiao[2].addEventListener("click" ,function(){
    vo.style.display="none";
    chadiao[2].style.display = "none";
});



var la = document.querySelector("#la");

var vd= document.querySelector("#vd");

var chadiao = document.querySelectorAll(".po-video>.chadiao");
console.log(chadiao[3]);
la.addEventListener("click" ,function(){
    vd.style.display = "block";
    chadiao[3].style.display = "block";
});

chadiao[3].addEventListener("click" ,function(){
    vd.style.display="none";
    chadiao[3].style.display = "none";
});
